package com.asha.md360player4android.vr.display;

import android.content.Context;
import android.graphics.Point;
import android.util.Log;

import com.asha.vrlib.MD360Director;
import com.asha.vrlib.strategy.display.DisplayModeManager;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fuyao on 2017/1/18.
 */

public class FourBlockStrategy extends AbsBlockStrategy {
    private static int DISPLAY_SIZE = 4;

    public FourBlockStrategy(DisplayModeManager.Params params) {
        super(params);
    }

    @Override
    public void turnOnInGL(Context context) {
        List<MD360Director> directors = getDirectorList();
        directors.get(0).setEyeZ(0f);
        directors.get(1).setEyeZ(0f);
        directors.get(2).setEyeZ(0f);
        directors.get(3).setEyeZ(0f);
        directors.get(3).reset();
        directors.get(3).setDeltaXEx(0f);
        directors.get(3).setDeltaYEx(DEFINE_X_EXTRA);
        directors.get(2).reset();
        directors.get(2).setDeltaXEx(180);
        directors.get(2).setDeltaYEx(DEFINE_X_EXTRA);
        directors.get(1).reset();
        directors.get(1).setDeltaXEx(90f);
        directors.get(1).setDeltaYEx(DEFINE_X_EXTRA);
        directors.get(0).reset();
        directors.get(0).setDeltaXEx(-90f);
        directors.get(0).setDeltaYEx(DEFINE_X_EXTRA);
    }

    @Override
    public void onSurfaceChanged(int width, int height) {
        mPoss = new ArrayList<>(DISPLAY_SIZE);
        mSizes = new ArrayList<>(DISPLAY_SIZE);
        mPoss.add(new Point(0, height / 2));
        mPoss.add(new Point(width / 2, height / 2));
        mPoss.add(new Point(0, 0));
        mPoss.add(new Point(width / 2, 0));
        mSizes.add(new Point(width / 2, height / 2));
        mSizes.add(new Point(width / 2, height / 2));
        mSizes.add(new Point(width / 2, height / 2));
        mSizes.add(new Point(width / 2, height / 2));
        Log.d("FUYAO_FourBlockStrategy", "onSurfaceChanged mSizes = " + mSizes + " mPoss = " + mPoss);
    }

    @Override
    public int getVisibleSize() {
        return DISPLAY_SIZE;
    }

    @Override
    public List<Point> getDisplayPoss() {
        return mPoss;
    }

    @Override
    public List<Point> getDisplaySizes() {
        return mSizes;
    }
}
